package com.control.qct.businesssteward.adapter;

import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.control.qct.businesssteward.R;
import com.control.qct.businesssteward.model.HomeModel;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by Administrator on 2017/11/23 0023.
 */

public class HomeAdapter extends BaseQuickAdapter<HomeModel, BaseViewHolder> {
    public HomeAdapter(@Nullable List<HomeModel> data) {
        super(R.layout.rv_home_type_item, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, HomeModel item) {
        Drawable drawable = mContext.getResources().getDrawable(item.getImg());
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        TextView tvTypeName = holder.getView(R.id.tv_type_name);
        tvTypeName.setCompoundDrawables(null, drawable, null, null);
        holder.setText(R.id.tv_type_name, item.getName());
        switch (item.getName()) {
            case "商品":
            case "订单":
            case "日结":
            case "盘点":
            case "报表":
                holder.setTextColor(R.id.tv_type_name, Color.parseColor("#333333"));
                break;
            default:
                holder.setTextColor(R.id.tv_type_name, Color.parseColor("#e1e1e1"));
                break;
        }
    }
}
